//
//  BaseTableViewController.swift
//  SinaWebo
//
//  Created by mis on 16/3/17.
//  Copyright © 2016年 mis. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate {
    
    var loginType = UserAccountViewModel().userLogin
//    var loginType = false
    var visitorLoginView : VisitorLoginView?
    
    override func loadView() {
        loginType ? super.loadView() : loadNewView()
    }
    
    private func loadNewView() {
        visitorLoginView = VisitorLoginView()
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
        
        visitorLoginView?.visitorDelegate = self
        
        view = visitorLoginView
    }
    

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    func userWillRegister() {
        print("come on")
    }
    
    func userWillLogin() {
        print("come in")
        let oaVC = OAuthViewController()
        let nav = UINavigationController(rootViewController: oaVC)
        presentViewController(nav, animated: true, completion: nil)
    }

}
